<<<<<<< HEAD
/*
 * @Author: your name
 * @Date: 2020-08-11 20:44:55
 * @LastEditTime: 2020-08-11 21:00:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \day01\demo5\main.go
 */
=======
>>>>>>> 4925e93374cf8c3a0dff85b9a22729f970dc1768
package main

import (
	"fmt"
<<<<<<< HEAD
	"log"
	"os"
)

func init() {
	logFile, err := os.OpenFile("./xx.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
	if err != nil {
		log.Panicln("打开失败，，，，")
		return
	}
	log.SetOutput(logFile)
	log.SetFlags(log.Llongfile | log.Lmicroseconds | log.Ldate)
	log.SetPrefix("[消息]")

}

func main() {

	log.Println("log println")
	// log.Output("log Output")
	log.Fatal("log Fatal")
	// log.Panicln("log panicln")

	fmt.Println("==============自定义logger==============")

	logger := log.New(os.Stdout, "<new>", log.Lshortfile|log.Ldate|log.Ltime)
	logger.Println("自定义logger")

}
=======
	"io/ioutil"
)

func main() {
	var cb demo5.ContackBook

	p1 = demo5.Person{
		Name:   "小猪",
		Gender: demo5.GenderType_MALE,
		Number: "78788",
	}
	fmt.Println(p1)
	cb.Persons = append(cb.Persons, &p1)
	// 序列化
	data, err := proto.Marshal(&p1)
	if err != nil {
		fmt.Printf("marshal failed,err:%v\n", err)
		return
	}
	ioutil.WriteFile("./proto.dat",data,0644)
	data2 ,err := ioutil.ReadFile("./proto.data")
	if err != nil {
		fmt.Printf("read file failed, err:%v\n", err)
		return
	}
	var p2 demo5.Person
	proto.Unmarshal(data2, &p2)
	fmt.Println(p2)
}
>>>>>>> 4925e93374cf8c3a0dff85b9a22729f970dc1768
